Ext.define('Seq.button.CrudButton', {
    alternateClassName: ['Seq.Btn'],

    singleton: true,

    button(cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            handler: fn
        }, cfg);
    },

    insert: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '新增',
            tooltip: '新建一条记录',
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-plus-square fa-action',
            handler: fn || 'onInsertClick'
        }, cfg);
    },

    del: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '删除',
            tooltip: '删除选中的记录',
            ui: 'soft-decline-o',
            iconCls: 'x-fa fa-remove fa-decline',
            handler: fn || 'onDeleteClick'
        }, cfg);
    },

    search: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-search fa-action',
            text: '查询',
            tooltip: '根据输入条件，查询结果',
            handler: fn || 'onQueryClick'
        }, cfg);
    },

    imp: function (cfg, fn) {
        return Ext.apply({
            xtype: 'filebutton',
            ui: 'soft-confirm-o',
            iconCls: 'x-fa fa-cloud-upload fa-confirm',
            text: '导入',
            tooltip: '从文件中批量导入数据',
            handler: fn || 'onImportClick'
        }, cfg);
    },

    sync: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            ui: 'soft-confirm-o',
            iconCls: 'x-fa fa-exchange fa-confirm',
            text: '同步',
            tooltip: '从其他系统同步数据',
            handler: fn || 'onSyncClick'
        }, cfg);
    },

    exp: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            border: false,
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-indent fa-action',
            tooltip: '将数据导出到文件',
            handler: fn || 'onExportClick'
        }, cfg);
    },

    invite: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '邀请',
            tooltip: '邀请用户参与',
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-user-plus fa-action',
            handler: fn || 'onInviteClick'
        }, cfg);
    },

    refresh: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '刷新',
            tooltip: '重新获取记录',
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-refresh fa-action',
            handler: fn || 'onRefreshClick'
        }, cfg);
    },

    read: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '读取',
            tooltip: '从终端设备读取配置',
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-cloud-upload fa-action',
            handler: fn || 'onReadClick'
        }, cfg);
    },

    write: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '设置',
            tooltip: '将配置下装到终端设备',
            ui: 'soft-decline-o',
            iconCls: 'x-fa fa-cloud-download fa-decline',
            handler: fn || 'onWriteClick'
        }, cfg);
    },

    save: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '保存',
            tooltip: '将修改记录保存到数据库中',
            ui: 'soft-confirm-o',
            iconCls: 'x-fa fa-save fa-confirm',
            handler: fn || 'onSaveClick'
        }, cfg);
    },

    prev: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            tooltip: '向前',
            border: false,
            iconCls: 'x-fa fa-angle-left fa-action',
            handler: fn || 'onPrevClick'
        }, cfg);
    },

    next: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            tooltip: '向后',
            border: false,
            iconCls: 'x-fa fa-angle-right fa-action',
            handler: fn || 'onNextClick'
        }, cfg);
    },

    calc: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            ui: 'soft-action',
            text: '计算',
            tooltip: '重新计算',
            iconCls: 'x-fa fa-calculator fa-action',
            handler: fn || 'onCalcClick'
        }, cfg);
    },

    zoomIn: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            tooltip: '放大',
            border: false,
            iconCls: 'x-fa fa-search-plus fa-action',
            handler: fn || 'onZoomInClick'
        }, cfg);
    },

    zoomOut: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            tooltip: '缩小',
            border: false,
            iconCls: 'x-fa fa-search-minus fa-action',
            handler: fn || 'onZoomOutClick'
        }, cfg);
    },

    reply: function (cfg, fn) {
        return Ext.apply({
            tooltip: '返回上级页面',
            xtype: 'button',
            border: false,
            ui: 'header',
            iconCls: 'x-fa fa-reply fa-blue',
            href: 'javascript:history.back(-1);',
            hrefTarget: '_self'
        }, cfg);
    },

    start: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '启动',
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-action fa-play',
            handler: fn || 'onStartClick'
        }, cfg);
    },

    stop: function (cfg, fn) {
        return Ext.apply({
            xtype: 'button',
            text: '停止',
            ui: 'soft-action-o',
            iconCls: 'x-fa fa-confirm fa-stop',
            handler: fn || 'onStopClick'
        }, cfg);
    }

})